package com.zhanbo.zhanbowymusic.main.featured.adapter;

import android.content.Context;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.mwx.baselib.base.BaseBindingAdapter;
import com.mwx.baselib.bean.RankingListBean;
import com.mwx.baselib.utils.DateUtils;
import com.mwx.baselib.utils.GlideUtils;
import com.zhanbo.zhanbowymusic.R;
import com.zhanbo.zhanbowymusic.databinding.ItemGuanfangBinding;
import com.zhanbo.zhanbowymusic.databinding.ItemHomeOfficialBinding;

public class FeaturedGuanFangAdapter extends BaseBindingAdapter<RankingListBean.ItemsDTO, ItemGuanfangBinding> {
    public FeaturedGuanFangAdapter(Context context) {
        super(context);
    }

    @Override
    protected int getLayoutResId(int viewType) {
        return R.layout.item_guanfang;
    }

    @Override
    protected void onBindItem(ItemGuanfangBinding binding, RankingListBean.ItemsDTO item) {
        binding.tvTitle.setText(item.getName()+"");
        binding.tvDate.setText(DateUtils.ISO8601Format(item.getUpdateTime())+"更新");
        FeaturedHomeOfficialMusicListAdapter featuredHomeOfficialMusicListAdapter  = new FeaturedHomeOfficialMusicListAdapter(context);
        featuredHomeOfficialMusicListAdapter.getItems().addAll(item.getSong());
        binding.rvMusicList.setLayoutManager(new LinearLayoutManager(context,LinearLayoutManager.VERTICAL,false));
        binding.rvMusicList.setAdapter(featuredHomeOfficialMusicListAdapter);
        featuredHomeOfficialMusicListAdapter.setOnItemClickListener(this.mOnItemClickListener);
        if (item.getSong().size()>0){
            GlideUtils.loadImageRounded10(context,item.getSong().get(0).getSong().getCoverImg(),binding.ivHead1);
        }
        if (item.getSong().size()>1){
            GlideUtils.loadImageRounded10(context,item.getSong().get(1).getSong().getCoverImg(),binding.ivHead2);
        }
        if (item.getSong().size()>2){
            GlideUtils.loadImageRounded10(context,item.getSong().get(2).getSong().getCoverImg(),binding.ivHead3);
        }
    }
}
